using System;
using System.Collections.Generic;

namespace Nairo.Parser.Dom
{
	public abstract class AbstractBlock : INode
	{
		protected INode parent;
		protected List<INode> children;
		protected object userData;
		protected FileUnit file;
		
		public AbstractBlock() : this(null, null, new List<INode>(), null)
		{
		}
		
		public AbstractBlock(FileUnit file, INode parent, List<INode> children, object userData)
		{
			this.file = file;
			this.parent = parent;
			this.children = children;
			this.userData = userData;
		}
		
		public virtual INode Parent {
			get { return this.parent; }
			set { this.parent = value; }
		}
		
		public virtual List<INode> Children {
			get { return this.children; }
			set { this.children = value; }
		}
		
		public virtual object UserData {
			get { return this.userData; }
			set { this.userData = value; }
		}
		
		public virtual FileUnit File {
			get { return this.file; }
		}
		
		public bool HasChildNodes {
			get { return this.children.Count > 0;}
		}
		
		public abstract INode GetTag(string name);
		public abstract INode[] GetTags(string name);
		
///		 <summary>
///		 Visits all children
///		 <summary>
///		 <param name="visitor">The visitor to accept<param>
///		 <param name="data">Additional data for the visitor<param>
///		 <returns>The paremeter <paramref name="data"><returns>
		public abstract object AcceptChildren(IDomVisitor visitor, object data);
		
///		 <summary>
///		 Accept the visitor
///		 <summary>
///		 <param name="visitor">The visitor to accept<param>
///		 <param name="data">Additional data for the visitor<param>
///		 <returns>The value the visitor returns after the visit<returns>
		public abstract object AcceptVisitor(IDomVisitor visitor, object data);
	}
}
